import {createRouter, createWebHashHistory} from 'vue-router'

import test2 from "`/test2.vue"

import user from "`/user/user.vue"
import browse from "`/user/browse/browse.vue"
import traffic from "`/user/browse/tab/traffic.vue"
import resource from "`/user/browse/tab/resource.vue"
import record from "`/user/record/record.vue"
import detail from "`/user/detail/detail.vue"
import snapshotDetail from "`/user/detail/detailItem/snapshotDetail.vue"
import resourceSnapshot from "`/user/detail/detailItem/resourceSnapshot.vue"
import trafficDetail from "`/user/detail/detailItem/trafficDetail.vue";
import resourceDetail from "`/user/detail/detailItem/resourceDetail.vue";

import supplier from "`/supplier/supplier.vue"
import supplierBrowse from "`/supplier/browse/supplierBrowse.vue";
import supplierTraffic from "`/supplier/browse/tab/supplierTraffic.vue"
import supplierResource from "`/supplier/browse/tab/supplierResource.vue"
import supplierTrafficDetail from "`/supplier/detail/supplierTrafficDetail.vue";
import supplierResourceDetail from "`/supplier/detail/supplierResourceDetail.vue";
import supplierRecord from "`/supplier/record/supplierRecord.vue"


import admin from "`/admin/admin.vue"
import adminBrowse from "`/admin/browse/adminBrowse.vue";
import adminTrafficDetail from "`/admin/detail/adminTrafficDetail.vue"
import adminResourceDetail from "`/admin/detail/adminResourceDetail.vue";
import adminTraffic from "`/admin/browse/tab/adminTraffic.vue";
import adminResource from "`/admin/browse/tab/adminResource.vue";

import chat from "~/components/Chat.vue"

const router = createRouter({
    history: createWebHashHistory(), // hash模式：createWebHashHistory，history模式：createWebHistory
    routes: [
        {
            path: '/admin',
            name: 'admin',
            component: admin,
            children: [
                {
                    path: "browse",
                    component: adminBrowse,
                    children: [
                        {path: ":productTypeStr(train|flight)", component: adminTraffic},
                        {path: ":productTypeStr(hotel|scenic)", component: adminResource},
                    ]
                },
                {
                    path:'detail/:productTypeStr(train|flight)/:id',component: adminTrafficDetail
                },
                {
                    path:'detail/:productTypeStr(hotel|scenic)/:id',component: adminResourceDetail
                },
                {
                    path: 'chat', component: chat
                }
            ]
        },
        {
            path: '/supplier',
            name: 'supplier',
            component: supplier,
            children: [
                {
                    path: "browse",
                    component: supplierBrowse,
                    children: [
                        {path: ":productTypeStr(train|flight)", component: supplierTraffic},
                        {path: ":productTypeStr(hotel|scenic)", component: supplierResource},
                    ]
                },
                {
                    path:'detail/:productTypeStr(train|flight)/:id',component: supplierTrafficDetail
                },
                {
                    path:'detail/:productTypeStr(hotel|scenic)/:id',component: supplierResourceDetail
                },

                {
                    path: "record/:productTypeStr(train|flight|hotel|scenic)",
                    component: supplierRecord
                },
                {
                    path: 'chat', component: chat
                }
            ]
        },
        {
            path: '/user',
            name: 'user',
            component: user,
            children: [
                {
                    path: "browse",
                    component: browse,
                    children: [
                        {path: ":productTypeStr(train|flight)", component: traffic},
                        {path: ":productTypeStr(hotel|scenic)", component: resource},
                    ]
                },
                {
                    path: "record/:productTypeStr(train|flight|hotel|scenic)",
                    component: record
                },
                {
                    path: 'detail', component: detail,
                    children: [
                        {path: ':productTypeStr(train|flight)/:id', component: trafficDetail},
                        {path: ':productTypeStr(hotel|scenic)/:id', component: resourceDetail},
                        {path: 'snapshot/:id', component: snapshotDetail},
                        {path: 'snapshot/resource/:id', component: resourceSnapshot}
                    ]
                },
                {
                    path: 'chat', component: chat
                },
            ]
        },
        {
            path: '/login',
            name: 'login',
            component: test2
        },
        {
            path: '/chat/:connectCas?',
            name: 'chat',
            component: chat
        }
    ]
})

export default router
